home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus 2004 #6 / Amiga Plus CD - 2004 - No. 06.iso / AmigaPlus / Tools / Dev_Libs / Amiblitz2 / thilo_includes / dbl_benchmark.ab2 < prev    next >
Text File  |  2003-02-13  |  5KB  |  155 lines

  1. optimize 7
  2. Syntax 2
  3. WBStartup
  4. !error_include
  5. !dbl_include   ;1,1 best For gfx card and if you want scrolling
  6. ;!dbl_include 0,0 ;best for AGA AND workbench games
  7.  
  8. #scrl     = 0    ; scroll background
  9. maxdepth.l = 1   ; max depth of screen
  10.  
  11. NEWTYPE.ball
  12. x.q
  13. y.q
  14. xs.q
  15. ys.q
  16. End NEWTYPE
  17.  
  18.  
  19. Dim List ball.ball(0)
  20. ballcounter.l  = 0
  21. message.s      = ""
  22. succ.l         = False
  23. balltyp.l      = 3
  24. breakme.l      = False
  25. scrl.l         = False
  26. Statement newmessage {}
  27. SHARED ball(),ballcounter,message.s,balltyp,ballsize.l,ballshot.l
  28. Format ""
  29. If balltyp=2 Then a.s = "64x64"
  30. If balltyp=3 Then a.s = "32x32"
  31. If balltyp=4 Then a.s = "16x16"
  32. message.s = "balls: "+Str$(ballcounter)+" / size: "+a.s+" / fps: "
  33. Format "000.00"
  34. End Statement
  35.  
  36.  
  37.  
  38. Statement ball_add {}
  39. SHARED ball(),ballcounter,message.s,balltyp,width.l,height.l
  40. If AddItem(ball())
  41.   ball()\x=Rnd(width),Rnd(height),(Rnd-.5)*20+1,(Rnd-.5)*20+1
  42.   ballcounter+1
  43. End If
  44. newmessage {}
  45. End Statement
  46.  
  47. Statement ball_remove {}
  48. SHARED ball(),ballcounter,message.s,balltyp
  49. ResetList ball()
  50. If NextItem(ball())
  51.   KillItem ball():ballcounter-1
  52. End If
  53. newmessage {}
  54. End Statement
  55.  
  56. path.s = "gfx/" ; set your path here, including "/" !
  57. !screen_ {0,"test","ram:test",3}
  58. width.l=!screen_width:height.l=!screen_height
  59. If  dbl_init {"MyGame",!screen_id,width,height,!screen_depth}
  60.     dbl_showpointer{}
  61.   dbl_setpen {1,144,144,144}                  ; set pen 1 so that we can see error messages
  62.   If image_load {1,path.s+"pattern"}
  63.     dbl_bgblitpattern{1,0,0,width,height}   ; blit the background pattern in window
  64.  
  65.     succ=image_load {2,path.s+"ball64x64",0}  ; set path above
  66.     succ&image_load {3,path.s+"ball32x32",0}
  67.     succ&image_load {4,path.s+"ball16x16",0}
  68.     image_midhandle {2}
  69.     image_midhandle {3}
  70.     image_midhandle {4}
  71.     If succ
  72.       count.l = 0
  73.       res.q   = 50
  74.  
  75.       While breakme=False
  76.         res=Timer:ResetTimer:If res=0 Then res=1
  77.         ev.l = Event
  78.         While ev = #IDCMP_VANILLAKEY
  79.           Select EventCode
  80.             Case 27
  81.               breakme = True
  82.             Case 97
  83.               ball_add{}
  84.             Case 114
  85.               ball_remove{}
  86.             Case 115
  87.               scrl=1-scrl
  88.               sxv.q= Rnd*2 * Sgn(Rnd-.5):syv.q=Rnd*2 * Sgn(Rnd-.5)
  89.             Case 99
  90.               balltyp+1:If balltyp=5 Then balltyp=2
  91.               newmessage {}
  92.             Case 109
  93.               If imagedat(2)\mask_ptr
  94.                 FreeMem imagedat(2)\mask_ptr,0 : imagedat(2)\mask_ptr = False
  95.                 FreeMem imagedat(3)\mask_ptr,0  : imagedat(3)\mask_ptr = False
  96.                 FreeMem imagedat(4)\mask_ptr,0  : imagedat(4)\mask_ptr = False
  97.               Else
  98.                 image_initmask{2,0}
  99.                 image_initmask{3,0}
  100.                 image_initmask{4,0}
  101.               End If
  102.  
  103.           End Select
  104.           ev.l = Event
  105.         Wend
  106.  
  107.         If scrl
  108.           scroll_x.l - sxv.q
  109.           scroll_y.l - syv.q
  110.           dbl_bgscroll{sxv.q,syv.q}
  111.           If sxv<0
  112.             dbl_bgblitpattern{1,0,0,-sxv,height,scroll_x,scroll_y}
  113.           Else
  114.             dbl_bgblitpattern{1,width-1-sxv,0,sxv,height,scroll_x,scroll_y}
  115.           End If
  116.            If syv<0
  117.             dbl_bgblitpattern{1,0,0,width,-syv,scroll_x,scroll_y}
  118.           Else
  119.             dbl_bgblitpattern{1,0,height-1-syv,width,syv,scroll_x,scroll_y}
  120.           End If
  121.         End If
  122.         dbl_flip{}           ; flip the doublebuffer !
  123.         dbl_unqueue{}        ; unblit all objects drawn with "dbl_q???" commands
  124.  
  125.  
  126.         ResetList ball()
  127.              If Joyb(0)=1 Then fireval.l+1:Else fireval=0
  128.         While NextItem(ball())
  129.          If   dbl_2imghit {balltyp,ball()\x,ball()\y,@@
  130.                -1,SMouseX,SMouseY}@@  ;@@ mean join next line to term
  131.                AND (fireval > 0 AND fireval < 2);last value increase for MG depend on magazine size
  132.                KillItem ball():ballcounter-1
  133.                ballshot+1
  134.           Else
  135.                ball()\x+ball()\xs*correctspeed.l
  136.                ball()\y+ball()\ys*correctspeed
  137.                If ball()\x<0 OR ball()\x>width  Then ball()\xs=-ball()\xs
  138.                If ball()\y<0 OR ball()\y>height Then ball()\ys=-ball()\ys
  139.                dbl_qblit {balltyp,ball()\x,ball()\y}     ;draw balls
  140.             End If
  141.         Wend
  142.         dbl_qprint {message.s+Str$(50/res)+" Score "+Str$(ballshot),10,10,2}  ; Print a text for 1 frame
  143.         ;dbl_qprint {message.s+Str$(1000/res),10,10,2}  ; Print a text for 1 frame
  144.         dbl_qprint {"ESC=exit  (a)dd ball (r)emove ball  (c)hange Type  (m)ask Toggle (s)croll",10,height-16,2}
  145.  
  146.         ;count.l+1:If count=20 Then count=0:res=Timer:ResetTimer:If res=0 Then res=1
  147.         loop       If Timer<1 Then Goto loop ;need for framerate limit
  148.                    correctspeed.l=Timer      ;need for same speed regardless on framerate
  149.  
  150.       Wend
  151.     End If
  152.   End If
  153. End If
  154. End  ;important allow autofree
  155.